const tbody = document.querySelector('#list-tbody')
getData()
function getData(){
    prom('./api/v1/shop/select.php').then(reg => {
        // console.log(reg);
    
        if(reg.code === 200){
            const {list} = reg.body

            let html = list.reduce((str,shop,index) => {
                // console.log(index);
                str += `<tr idx="${shop.id}">
                            <td>${index+1}</td>
                            <td><span>${shop.name}</span><input type="text"></td>
                            <td><span>${shop.price}</span><input type="text"></td>
                            <td><span>${shop.num}</span><input type="text"></td>
                            <td>
                            <button class="btn btn-xs  btn-info btn-edit">编辑</button>
                            <button class="btn btn-xs btn-del btn-danger">删除</button>
                            <button class="btn btn-xs btn-ok btn-success">确定</button>
                            <button class="btn btn-xs btn-cancel btn-warning">取消</button>
                            </td>
                        </tr>`
                return str

            },'')    
            tbody.innerHTML = html
        } else {
            alert('网络失败，请重试')
        }  
    })
}


